package com.ruoyi.industryfrontend.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.industryfrontend.domain.SpaceIndustry;
import com.ruoyi.industryfrontend.mapper.SpaceIndustryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.industryfrontend.mapper.SpaceCollectMapper;
import com.ruoyi.industryfrontend.domain.SpaceCollect;
import com.ruoyi.industryfrontend.service.ISpaceCollectService;

/**
 * 空间收藏Service业务层处理
 *
 * @author MagicCube
 * @date 2023-05-23
 */
@Service
public class SpaceCollectServiceImpl implements ISpaceCollectService
{
    @Autowired
    private SpaceCollectMapper spaceCollectMapper;

    @Autowired
    private SpaceIndustryMapper spaceIndustryMapper;

    /**
     * 查询空间收藏
     *
     * @param id 空间收藏主键
     * @return 空间收藏
     */
    @Override
    public SpaceCollect selectSpaceCollectById(Long id)
    {
        return spaceCollectMapper.selectSpaceCollectById(id);
    }

    /**
     * 查询空间收藏列表
     *
     * @param spaceCollect 空间收藏
     * @return 空间收藏
     */
    @Override
    public List<SpaceIndustry> selectSpaceCollectList(SpaceCollect spaceCollect)
    {
        spaceCollect.setUserId(SecurityUtils.getUserId());
        return spaceIndustryMapper.selectSpaceCollectListz(spaceCollect);
    }

    /**
     * 新增空间收藏
     *
     * @param spaceCollect 空间收藏
     * @return 结果
     */
    @Override
    public int insertSpaceCollect(SpaceCollect spaceCollect)
    {
        spaceCollect.setUserId(SecurityUtils.getUserId());
        spaceCollect.setCreateTime(DateUtils.getNowDate());
        return spaceCollectMapper.insertSpaceCollect(spaceCollect);
    }

    /**
     * 修改空间收藏
     *
     * @param spaceCollect 空间收藏
     * @return 结果
     */
    @Override
    public int updateSpaceCollect(SpaceCollect spaceCollect)
    {
        return spaceCollectMapper.updateSpaceCollect(spaceCollect);
    }

    /**
     * 批量删除空间收藏
     *
     * @param ids 需要删除的空间收藏主键
     * @return 结果
     */
    @Override
    public int deleteSpaceCollectByIds(Long[] ids)
    {
        return spaceCollectMapper.deleteSpaceCollectByIds(ids);
    }

    /**
     * 删除空间收藏信息
     *
     * @param id 空间收藏主键
     * @return 结果
     */
    @Override
    public int deleteSpaceCollectById(String id)
    {
        return spaceCollectMapper.deleteSpaceCollectById(id,SecurityUtils.getUserId());
    }
}
